define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: '/mp/admin/mp_push_log',
        add_url: '/mp/admin/mp_push_log/create',
        edit_url: '/mp/admin/mp_push_log/edit',
        delete_url: '/mp/admin/mp_push_log/destroy',
        preview_url: '/mp/admin/mp_push_log/preview',
        push_url: '/mp/admin/mp_push_log/push',
    };

    return {

        index: function () {

            ea.table.render({
                init: init,
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', minWidth: 80, title: 'ID'},
                    {field: 'name', minWidth: 80, title: '任务名称'},
                    {field: 'article_id', minWidth: 80, title: '文章ID'},
                    {field: 'appid', minWidth: 80, title: 'AppId'},
                    {field: 'account.type', minWidth: 80, title: '发布平台'},
                    {field: 'media_id', minWidth: 80, title: '素材ID'},

                    {field: 'created_at', minWidth: 120, title: '创建时间'},
                    {field: 'updated_at', minWidth: 120, title: '更新时间'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '预览',
                                url: init.preview_url,
                                method: 'open',
                                auth: 'password',
                                class: 'layui-btn layui-btn-normal layui-btn-xs',
                            },{
                                text: '推送',
                                url: init.push_url,
                                method: 'open',
                                auth: 'password',
                                class: 'layui-btn layui-btn-xs',
                            }],
                            'edit',
                            'delete'
                        ]
                    }
                ]],
            });

            ea.listen();
        },
        create: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        preview: function () {
            ea.listen();
        },
        push: function () {
            ea.listen();
        }
    };
});
